<template>
    <div class="wrapper">
        <h2>开关组件</h2>
        <div class="shape">
            <h3>效果展示</h3>
            <div>
                <Switch v-model:value="bool" />
            </div>
        </div>
        <div class="markdown-body">
            
<pre><code>{{
`<Switch v-model:value="bool" />
<!-- 接受一个布尔值控制开关 -->`
}}</code></pre>
        </div>
        <div class="shape">
            <h3 @click="getCode">查看源码</h3>
            <main class="markdown-body" v-show="code">
<pre><code>{{
`<template>
    <Switch v-model:value="bool" />
</template>

<script>
import Switch from "../lib/Switch.vue"
import {ref} from "vue"
export default {
    components:{Switch},
    setup(){
        const bool = ref(true)
        return {bool}
    }
}
</script>`
}}</code></pre>
            </main>
        </div>
    </div>
</template>

<script lang = ts>
import Switch from "../lib/Switch.vue"
import {ref} from "vue"
    export default {
        components:{Switch},
        setup(){
            const code=ref(false)
            const bool = ref(true)
            const getCode=()=>{
                code.value=!code.value
            }
            return {bool,code,getCode}
        }
    }
</script>

<style lang="scss" scoped>
.wrapper{
    max-width:800px;
    h2{
        padding-bottom: 30px;
        border-bottom: 1px solid rgb(212, 208, 208);
    }
    .shape{
        margin:30px 0px;
        >h3{
            margin-bottom: 10px;
        }
        >div{
            display: flex;
            padding: 50px;
            align-items: center;
            justify-content: center;
            border:1px solid rgb(212, 208, 208);
        }
    }
}
</style>